﻿' Copyright (c) 2013  Christoc.com
'  All rights reserved.
' 
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
' 

Imports System.Collections.Generic
Imports DotNetNuke.Data

Namespace Components

    Public Class GooglSearchSettingController
        Public Sub CreateGooglSearchSetting(ByVal s As GooglSearchSetting)
            Using ctx As IDataContext = DataContext.Instance()
                Dim rep As IRepository(Of GooglSearchSetting) = ctx.GetRepository(Of GooglSearchSetting)()
                rep.Insert(s)
            End Using
        End Sub

        Public Sub DeleteGooglSearchSetting(ByVal s As Integer, ByVal moduleId As Integer)
            Dim _GooglSearchSetting As GooglSearchSetting = GetGooglSearchSetting(s, moduleId)
            DeleteGooglSearchSetting(_GooglSearchSetting)
        End Sub

        Public Sub DeleteGooglSearchSetting(ByVal s As GooglSearchSetting)
            Using ctx As IDataContext = DataContext.Instance()
                Dim rep As IRepository(Of GooglSearchSetting) = ctx.GetRepository(Of GooglSearchSetting)()
                rep.Delete(s)
            End Using
        End Sub

        Public Function GetGooglSearchSettings(ByVal _moduleId As Integer) As IEnumerable(Of GooglSearchSetting)
            Dim s As IEnumerable(Of GooglSearchSetting)

            Using ctx As IDataContext = DataContext.Instance()
                Dim rep As IRepository(Of GooglSearchSetting) = ctx.GetRepository(Of GooglSearchSetting)()
                s = rep.Get(_moduleId)
            End Using
            Return s
        End Function

        Public Function GetGooglSearchSetting(ByVal SettingId As Integer, ByVal moduleId As Integer) As GooglSearchSetting
            Dim s As GooglSearchSetting

            Using ctx As IDataContext = DataContext.Instance()
                Dim rep As IRepository(Of GooglSearchSetting) = ctx.GetRepository(Of GooglSearchSetting)()
                s = rep.GetById(Of Int32, Int32)(SettingId, moduleId)
            End Using
            Return s
        End Function

        Public Sub UpdateGooglSearchSetting(ByVal s As GooglSearchSetting)
            Using ctx As IDataContext = DataContext.Instance()
                Dim rep As IRepository(Of GooglSearchSetting) = ctx.GetRepository(Of GooglSearchSetting)()
                rep.Update(s)
            End Using
        End Sub

    End Class

End Namespace